package sg.edu.ntu.metaweb.storage.data;


public class Tag extends Contribution {

	private String text;
	
	public Tag(User creator, String text) {
		super(creator);
		this.text = text;
	}
	
	
	@Override 
	public boolean equals(Object obj) {
		
		if (obj == null) 
			return false;
		
		if (obj.getClass() != this.getClass()) 
			return false;
		
		Tag t = (Tag)obj;
		if ((this.text == t.text) && 
			(this.contributor == t.contributor))
			return true;
		
		return false;		
	}
	
	@Override
	public int hashCode() {
        
		String string = this.contributor.geteMailAddress() + this.text;

        byte[] byteValue = string.getBytes();
        int hash = 0;
        int len = byteValue.length;
        for (int i = 0 ; i < len; i++) {
        	hash <<= 1;
        	if ( hash < 0 ) hash |= 1;
        	hash ^= byteValue[ i ];
        }
        return hash;
    }
}